package entity

import (
	"shqsoft.cn/pasnj/base"

	"github.com/jinzhu/gorm"
)

//GJYWDR 国际结算量导入
type GJYWDR struct {
	ID    int     `gorm:"AUTO_INCREMENT;primary_key;column:ID"`
	KHYF  int     `gorm:"column:KHYF"`
	KHJL  string  `gorm:"column:KHJL;size:100"`
	DZ    float64 `gorm:"column:DZ"`
	HK    float64 `gorm:"column:HK"`
	GNZ   float64 `gorm:"column:GNZ"`
	SWIFT float64 `gorm:"column:SWIFT"`
	JSH   float64 `gorm:"column:JSH"`
	XYZ   float64 `gorm:"column:XYZ"`
	XGZS  float64 `gorm:"column:XGZS"`
	RZLR  float64 `gorm:"column:RZLR"`
}

//gjywAfterImport 导入后执行
func gjywAfterImport(tx *gorm.DB, params map[string]string) (err error) {
	err = tx.Exec("UPDATE T_BASE_YXFY_GJYW SET EMID=B.ID "+
		"FROM T_BASE_YXFY_GJYW A INNER JOIN T_SysUser B ON (A.KHJL=B.SysUserName) OR (A.KHJL=B.SysUserID)"+
		"WHERE KHYF=?", params["KHYF"]).Error
	if err != nil {
		return err
	}
	return nil
}

//TableName 国际中收导入表
func (GJYWDR) TableName() string {
	return "T_BASE_YXFY_GJYW"
}

//GJYWDREF 返回结构体
func GJYWDREF() base.EntityFunc {
	return func() interface{} {
		entity := GJYWDR{}
		return &entity
	}
}

//GJYWDRESF 返回结构体数组
func GJYWDRESF() base.EntitiesFunc {
	return func() interface{} {
		var entities []GJYWDR
		return &entities
	}
}

func init() {
	base.DaoPoolObj.Put("GJYWDR", base.NewDefaultDao(GJYWDREF(), GJYWDRESF(), nil))
	base.SetAfterCallBack("GJYWDR", gjywAfterImport)

}
